/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entidade;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author bruno
 */
@Entity
@Table(name = "conta")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Conta.findAll", query = "SELECT c FROM Conta c"),
    @NamedQuery(name = "Conta.findByIdConta", query = "SELECT c FROM Conta c WHERE c.idConta = :idConta"),
    @NamedQuery(name = "Conta.findByNomeConta", query = "SELECT c FROM Conta c WHERE c.nomeConta = :nomeConta"),
    @NamedQuery(name = "Conta.findByNumeroConta", query = "SELECT c FROM Conta c WHERE c.numeroConta = :numeroConta")})
public class Conta implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "idConta")
    private Integer idConta;
    @Size(max = 45)
    @Column(name = "nomeConta")
    private String nomeConta;
    @Column(name = "numeroConta")
    private Integer numeroConta;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idConta")
    private Collection<ContaMoeda> contaMoedaCollection;
    @JoinColumn(name = "idTipoConta", referencedColumnName = "idTipoConta")
    @ManyToOne(optional = false)
    private TipoConta idTipoConta;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idConta")
    private Collection<MovimentoConta> movimentoContaCollection;

    public Conta() {
        this.idConta = 0;
    }

    public Conta(Integer idConta) {
        this.idConta = idConta;
    }

    public Integer getIdConta() {
        return idConta;
    }

    public void setIdConta(Integer idConta) {
        this.idConta = idConta;
    }

    public String getNomeConta() {
        return nomeConta;
    }

    public void setNomeConta(String nomeConta) {
        this.nomeConta = nomeConta;
    }

    public Integer getNumeroConta() {
        return numeroConta;
    }

    public void setNumeroConta(Integer numeroConta) {
        this.numeroConta = numeroConta;
    }

    @XmlTransient
    public Collection<ContaMoeda> getContaMoedaCollection() {
        return contaMoedaCollection;
    }

    public void setContaMoedaCollection(Collection<ContaMoeda> contaMoedaCollection) {
        this.contaMoedaCollection = contaMoedaCollection;
    }

    public TipoConta getIdTipoConta() {
        return idTipoConta;
    }

    public void setIdTipoConta(TipoConta idTipoConta) {
        this.idTipoConta = idTipoConta;
    }

    @XmlTransient
    public Collection<MovimentoConta> getMovimentoContaCollection() {
        return movimentoContaCollection;
    }

    public void setMovimentoContaCollection(Collection<MovimentoConta> movimentoContaCollection) {
        this.movimentoContaCollection = movimentoContaCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idConta != null ? idConta.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Conta)) {
            return false;
        }
        Conta other = (Conta) object;
        if ((this.idConta == null && other.idConta != null) || (this.idConta != null && !this.idConta.equals(other.idConta))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return nomeConta;
    }
    
}
